package com.pktechan.api.enumeration;

public enum YesOrNoEnum {

    YES(1, "是"),
    NO(0, "否");

    private Integer code;
    private String name;

    YesOrNoEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据状态代码获得状态名称
     *
     * @param code 状态代码
     * @return 状态名称
     */
    public static String getNameByCode(Integer code) {
        for (YesOrNoEnum statusEnum : YesOrNoEnum.values()) {
            if (statusEnum.code.equals(code)) {
                return statusEnum.name;
            }
        }
        return null;
    }
}
